﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web.master" AutoEventWireup="true"
    CodeFile="UserManage.aspx.cs" Inherits="Platform_UserManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script src="../Scripts/YJPopup.js" type="text/javascript"></script>
    <script src="../Scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="../Scripts/validform.js" type="text/javascript"></script>
    <script src="../Scripts/GiveTip.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        var MyPopup;
        $(function () {
            MyPopup = new YJPopup({
                contentDivID: "YJContentDiv",
                dragBarDivID: "YJDragBar",
                dragable: false,
                autoCreate: true
            });
            $.checkForm();

            $("input[id$='txtMobile']").bind("input propertychange", function () {
                var val = $(this).val();
                if (val.length == 11) {
                    $.ajax({
                        type: "post",
                        url: '<%=ResolveClientUrl("~/Ashx/system.ashx") %>?action=checkUser&uname=' + val + '&k=' + Math.random(),
                        error: function () {
                            $("#checkResult").html('验证出错');
                            $(":input[id$='btnSave']").attr('class', 'btn-disabled');
                            $(":input[id$='btnSave']").attr("disabled", "disabled");
                        },
                        success: function (data) {
                            var obj = eval("(" + data + ")").result;
                            if (obj.r == "suc") {
                                $("#checkResult").html(obj.val);
                                $(":input[id$='btnSave']").attr('class', 'btn');
                                $(":input[id$='btnSave']").removeAttr('disabled');
                            } else {
                                $("#checkResult").html(obj.val);
                                $(":input[id$='btnSave']").attr('class', 'btn-disabled');
                                $(":input[id$='btnSave']").attr("disabled", "disabled");
                            }
                        },
                        complete: function () {
                        }
                    });
                }
                else {
                    $("#checkResult").html('默认密码是用户名');
                    $(":input[id$='btnSave']").attr('class', 'btn-disabled');
                    $(":input[id$='btnSave']").attr("disabled", "disabled");
                }
            });
        });
        function ShowUserInfo(UserID) {
            MyPopup.Show("90%", "300px", "员工信息修改", "UserModify.aspx?UserID=" + UserID);
        }
        function ShowRoleInfo(UserID) {
            MyPopup.Show("300px", "300px", "岗位调整", "UserRoles.aspx?UserID=" + UserID);
        }
        function UaerCom(UserID) {
            MyPopup.Show("600px", "400px", "负责小区", "UaerComSet.aspx?UserID=" + UserID);
        }
        function ClosePopup() {
            MyPopup.Hide();
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <table class="tabContent">
        <tr>
            <th lang="th">
                用户添加
            </th>
        </tr>
        <tr>
            <td lang='td'>
                <table style="border-collapse: separate" cellpadding="4" cellspacing="4">
                    <tr>
                        <td align="right" style="width: 80px">
                            用户名：
                        </td>
                        <td>
                            <NC:FTextBox ID="txtMobile" runat="server" Width="150px" placeholder="手机号" CheckGroup="Add"
                                CheckType="Phone" />
                            <span id="checkResult" class="tip"></span>
                        </td>
                        <td align="right" style="width: 80px">
                            姓名：
                        </td>
                        <td>
                            <NC:FTextBox ID="txtTrueName" runat="server" Width="150px" CheckGroup="Add" />
                        </td>
                        <td align="right">
                            身份证：
                        </td>
                        <td align="left">
                            <NC:FTextBox ID="txtCardNumber" runat="server" CheckGroup="Add" CheckType="IDCard"
                                EnableNull="true" Width="150px" />
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            部门：
                        </td>
                        <td>
                            <NC:FDropdownList ID="ddlDept" runat="server" Width="155px" CheckGroup="Add">
                            </NC:FDropdownList>
                        </td>
                        <td align="right">
                            排序：
                        </td>
                        <td align="left">
                            <NC:FTextBox ID="txtPaiXu" runat="server" Width="150px" CheckType="Int" CheckGroup="Add">0</NC:FTextBox>
                        </td>
                        <td align="right">
                            岗位：
                        </td>
                        <td align="left">
                            <asp:CheckBoxList ID="SysRole" runat="server" DataTextField="RoleName" DataValueField="RoleName"
                                RepeatDirection="Horizontal">
                            </asp:CheckBoxList>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" align="center">
                            <asp:Button ID="btnSave" runat="server" class="btn-disabled" disabled='disabled'
                                Text="添 加" CheckGroup="Add" OnClick="btnSave_Click" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <th colspan="4" lang="th">
                用户列表
            </th>
        </tr>
        <tr>
            <td lang="td">
                <table style="border-collapse: separate" cellpadding="4" cellspacing="4">
                    <tr>
                        <td>
                            用户名：
                        </td>
                        <td>
                            <NC:FTextBox ID="Mobile" runat="server" Width="100px" EnableCheck="false" />
                        </td>
                        <td>
                            姓名：
                        </td>
                        <td>
                            <NC:FTextBox ID="TrueName" runat="server" Width="70px" EnableCheck="false" />
                        </td>
                        <td>
                            部门：
                        </td>
                        <td>
                            <NC:FDropdownList ID="Dept" runat="server" Width="155px" EnableCheck="false">
                            </NC:FDropdownList>
                        </td>
                        <td>
                            <asp:Button ID="btnSearch" runat="server" class="btn btn3" OnClick="btnSearch_Click"
                                Text="查 找" />
                        </td>
                    </tr>
                </table>
                <NC:FGridView ID="FGridView1" runat="server" AutoCreateNumber="true" ShowFooter="true"
                    Width="100%">
                    <Columns>
                        <asp:BoundField DataField="Mobile" HeaderText="用户名">
                            <ItemStyle HorizontalAlign="Left" Width="100px" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="TrueName" HeaderText="姓名">
                            <ItemStyle HorizontalAlign="Left" Width="100px" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Sex" HeaderText="性别">
                            <ItemStyle HorizontalAlign="Left" Width="50px" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="CardNumber" HeaderText="身份证">
                            <ItemStyle HorizontalAlign="Left" Width="150px" />
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="部门">
                            <ItemTemplate>
                                <%# NS.BLL.Systems.DeptService.GetDeptNameByDeptID(Convert.ToString(Eval("DeptID")))%>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="岗位">
                            <ItemTemplate>
                                <%# NS.BLL.Systems.UsersInRolesService.GetUserRoles(Convert.ToString(Eval("UserID")))%>
                            </ItemTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="OrderNum" HeaderText="排序" ItemStyle-Width="60px" ItemStyle-HorizontalAlign="Center" />
                        <asp:TemplateField HeaderText="详情">
                            <ItemStyle HorizontalAlign="Center" Width="50px" />
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemTemplate>
                                <input id="btnView" type="button" value="修改" class="Gridbtn" onclick="ShowUserInfo('<%#Eval("UserID") %>')" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="岗位">
                            <ItemStyle HorizontalAlign="Center" Width="50px" />
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemTemplate>
                                <input type="button" value="调整" class="Gridbtn" onclick="ShowRoleInfo('<%# Eval("UserID") %>')" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="密码">
                            <ItemStyle HorizontalAlign="Center" Width="50px" />
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemTemplate>
                                <asp:Button ID="btnRePWD" runat="server" Text="重置" class="Gridbtn" CommandArgument='<%# Eval("UserID") %>'
                                    OnClientClick="return GiveTip(event,'您确定重置此用户的密码吗？')" OnClick="btnRePWD_Click" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="删除">
                            <ItemStyle HorizontalAlign="Center" Width="50px" />
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemTemplate>
                                <asp:Button ID="btnDel" runat="server" Text="删除" class="Gridbtn" CommandArgument='<%# Eval("UserID") %>'
                                    OnClientClick="return GiveTip(event,'您确定删除吗？')" OnClick="btnDel_Click" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </NC:FGridView>
            </td>
        </tr>
    </table>
</asp:Content>
